package newtank.network.server.handler;

import io.netty.channel.ChannelHandlerContext;
import server.code.ResponseStatus;
import server.netty.GpcDataPackage;
import tool.GlobalUniqueGenerator;

/**
 * @author lijiahao
 * @since 2021/12/8
 */
public class ConnectionDataHandler extends AbstractDataHandler {

    @Override
    public void handle(ChannelHandlerContext ctx, GpcDataPackage data) {
        GpcDataPackage gpc = new GpcDataPackage();
        gpc.setStatus(1);
        gpc.setCode(ResponseStatus.accepted);
        gpc.setContext("建立连接请求");
        gpc.setUnique(getClientIdentity());
        gpc.setIndex(GlobalUniqueGenerator.getGlobalId());
        ctx.writeAndFlush(gpc);
    }
}
